﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    public class FullArrangement
    {
        public const int MAX_NUM = 10;
        public static int[] numbers = new int[MAX_NUM];
        public static int length;

        public static void Arrangement(int[] nums, int pos)
        {
            PrintfNum(nums);
            for (int i = length - 2; i > pos - 1; i--)
                next_arrange(nums, i);
        }
        static void next_arrange(int[] nums, int pos)
        {
            int[] cop = new int[MAX_NUM];
            for (int i = pos + 1; i < length; i++)
                if (nums[i] > nums[pos] && nums[i] != nums[i - 1])
                {
                    for (int t = 0; t < length; t++)
                        cop[t] = nums[t];
                    for (int j = i; j > pos; j--)
                    {
                        int temp = cop[j];
                        cop[j] = cop[j - 1];
                        cop[j - 1] = temp;
                    }
                    Arrangement(cop, pos + 1);
                }
        }
        static void PrintfNum(int[] num)
        {
            for (int i = 0; i < length; i++)
                Console.Write(num[i]);
            Console.WriteLine();
        }
    }
}
